<?php
//huydang1920
function seo_trim_all($string) {
	$cach = false;
	$returnstr = "";	
	$string = trim($string);		
	$strlen = strlen($string);
	for($i = 0; $i<$strlen; $i++){
		if($string[$i] == " "){
			if(!$cach){
				$returnstr .= " ";
				$cach = true;
			}
		}else{
			$returnstr .= $string[$i];
			$cach = false;
		}
	}
	return $returnstr;
}	

function seo_url($string){
	$string =  strtolower(seo_trim_all(utf8_to_ascii($string)));
	$stringt = "";
	$string = str_split($string,1);
	//echo ord('a') . "--";//97
	//echo ord('z'). "--";//122
	//echo ord('A'). "--";//65
	//echo ord('Z'). "--";//90
	//echo ord('0'). "--";//48
	//echo ord('9'). "--";//57
	$i = 0;
	$dacach = true;
	foreach($string as $char){
		$i = ord($char);
		if(($i >= 97 && $i <= 122) || ($i >= 48 && $i <= 57) || ($i == 45)){
			$stringt .= $char;
			$dacach = false;
		}
		else if($char == ' ' && $dacach == false){
			$stringt .= '-';
			$dacach = true;
		}
	}
	return $stringt;				
}
?>